#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll l, r, d[13][5][10][4];
int A[20];

//state:0, 1, 2, 3: null, 4, 8, 4 && 8

ll dp(int p, int c, int n, int s, bool flg, bool z){
    if(p==0) return c==3 && s!=3;
    if(s == 3) return 0;
    if(c + p <3) return 0;
    if(flg && !z && d[p][c][n][s]) return d[p][c][n][s];
    int x = flg?9:A[p];
    ll ans = 0;
    for (int i = 0; i <= x; ++i) {
        int tc = c==3?3:(n==i?c+1:1);
        int ts = s;
        if(i == 4) ts |= 1;
        if(i == 8) ts |= 2;
        if(z && i==0) ans += dp(p-1, 0, 0, 0, flg||i<x, true);
        else ans += dp(p-1, tc, i, ts, flg||i<x, false);
    }
    if(flg) d[p][c][n][s] = ans;
    return ans;
}

ll cal(ll x){
    int p = 0;
    while (x){
        A[++p] = x%10;
        x/=10;
    }
    return dp(p, 0, 0, 0, false, true);
}


int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    cin >> l >> r;
    cout << cal(r) - cal(l-1);
    return 0;
}